/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.knowledge.plans;

import com.environment.Order;
import com.environment.Percept;
import com.knowledge.facts.FactRepository;
import com.knowledge.facts.FriendlyAntFact;
import com.knowledge.facts.IntendedLocationFact;
import java.util.HashSet;
import java.util.Set;

/**
 *
 * @author keithballantyne
 */
public class GoalPlan {
    private Set<Order> orders = new HashSet<Order>();
    
    public Set<Order> getOrders() {
        return orders;
    }   
    
    public void addOrders(Set<Order> orders) {
        this.orders.addAll(orders);
    }

    public void issueOrders() {
        for (Order order: orders) {
            IntendedLocationFact movement = new IntendedLocationFact(order.toDestinationTile());
            IntendedLocationFact noMovement = new IntendedLocationFact(order.getLocation());
            
            if (!FactRepository.getInstance().hasFactInstance(movement)) {
                System.out.println(order);
                System.out.flush();
                FactRepository.getInstance().addInstance(movement);
                FactRepository.getInstance().removeInstance(noMovement);
            } 
        }
    }

}
